// pages/keepcar/hiscarsrv.js
var util = require('../../utils/util.js');
const app = getApp()
var page = 1;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    listInfo: [],
    orderlists: [],
    planlists: [],
    loading: true,
    userinfo: '',
    showModalStatus: false,
    animationData: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    page = 1;
    if (!app.globalData.isLoginAuth) {
      this.showModal();
    }
  },

  /**
     * 生命周期函数--监听页面初次渲染完成
     */
  onReachBottom: function () {
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function (e) {
    if (app.globalData.isLoginAuth) {
      this.setData({
        listInfo: app.globalData.listInfo
      })
      this.getApplylist();
    }
  },
  getApplylist: function () {
    var that = this;
    var uid = wx.getStorageSync('userId');
    wx.request({
      url: app.globalData.hostUrl + 'member/myhisordlist',
      data: {
        uid: uid
      },
      methods: 'GET',
      header: {
        "Content-Type": "json"
      },
      success: function (res) {
        console.log(res);
        if (res.data.result) {
          that.setData({
            orderlists: res.data.result.lists,
          });
        }
        else {
          that.setData({
            loading: false
          })
          return false
        }
      }
    })
  },
  calling: function (e) {
    var mobile = e.currentTarget.dataset.phone;
    wx.makePhoneCall({
      phoneNumber: mobile,
      success: function () {
        //console.log("拨打电话成功！")
      },
      fail: function () {
        // console.log("拨打电话失败！")
      }
    })
  },
 
  goorderdetail: function (e) {
    var rid = e.currentTarget.dataset.id;
    var cf = e.currentTarget.dataset.cf;
    var gotourl = '../keepcar/carsrvdetail?oid=' + rid + '&cf=' + cf;
    if (cf == 'bz' || cf == 'hz')
      gotourl = '../keepcar/paperdetail?oid=' + rid + '&cf=' + cf;
    wx.navigateTo({
      url: gotourl
    })
  },
  gohome: function () {
    wx.redirectTo({
      url: '../index/index',
    })
  },
  yuy: function () {
    if (1 == wx.getStorageSync('roleidentity')) {
      wx.redirectTo({
        url: '../keepcar/mycarsrv',
      })
    }
    else {
      wx.redirectTo({
        url: '../keepcar/adcarsrv',
      })
    }
  },
  orders: function () {
    if (1 == wx.getStorageSync('roleidentity')) {
      wx.redirectTo({
        url: '../keepcar/carsrvmanage',
      })
    }
    else {
      wx.redirectTo({
        url: '../keepcar/hiscarsrv',
      })
    }
  },
  mys: function () {
    wx.redirectTo({
      url: '../myself/myself',
    })
  },
  showModal: function () {
    // 显示遮罩层
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "ease-in-out",
      delay: 0
    })
    this.animation = animation
    animation.translateY(500).step()
    this.setData({
      animationData: animation.export(),
      showModalStatus: true
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export()
      })
    }.bind(this), 200)
  },
  hideModal: function () {
    this.setData({
      showModalStatus: false,
    })
  },
  bindGetUserInfo: function (e) {
    console.log(e);
    if (e.detail.errMsg == 'getUserInfo:ok') {
      app.globalData.userInfo = e.detail.userInfo;
      app.getfansinfo();
    }
    else {
      wx.redirectTo({
        url: '../index/index',
      })
    }
  }
})